<?php
	class Login extends CI_Controller 
	{

    	function admin_index() 
		{
        	$this->load->view('admin/login_view');
    	}

    	function CheckLoginAdmin() 
		{
        	$username = $this->input->post('username');
	        $password = $this->input->post('password');

    	    $this->load->model('nhanvien_model');
        	$result = $this->nhanvien_model->CheckLogin($username, $password);
	        if ($result == 1) 
			{
	            $chucvu = $this->nhanvien_model->GetChucVu($username);
    	        $manv = $this->nhanvien_model->LayMaNV($username);
        	    $session_data = array('manv' => $manv, 'username' => $username, 'islogin' => 1, 'chucvu' => $chucvu);
            	$this->session->set_userdata($session_data);
	            redirect('phieudatphong/admin_index');
    	    }
        	else
            	redirect('login/admin_index');
    	}

	    function LogoutAdmin() 
		{
        	$this->session->unset_userdata('manv');
	        $this->session->unset_userdata('username');
    	    $this->session->unset_userdata('islogin');
	        $this->session->unset_userdata('chucvu');
    	    $this->session->sess_destroy();
        	redirect('login/admin_index', 'refresh');
	    }
	}
?>